home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / sound / soundapp / soundunit.h < prev   
Encoding:
Text File  |  2000-09-28  |  4.9 KB  |  124 lines

  1. /*
  2.     File:        SoundUnit.h
  3.  
  4.     Contains:    
  5.  
  6.     Written by: Jim Reekes    
  7.  
  8.     Copyright:    Copyright © 1994-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/29/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24.  
  25. #ifndef __SOUNDUNIT__
  26. #define __SOUNDUNIT__
  27.  
  28. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. // constants
  30. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31.  
  32. //refer to the SoundAppSnds.r file for documentation on these values
  33. enum {
  34.     kOctave1    = 0,                    //octaves of MIDI values
  35.     kOctave2    = 12,
  36.     kOctave3    = 24,
  37.     kOctave4    = 36,
  38.     kOctave5    = 48,
  39.     kOctave6    = 60,
  40.     kOctave7    = 72,
  41.     kOctave8    = 84,
  42.     kOctave9    = 96,
  43.     kOctave10    = 108,
  44.     kOctave11    = 120,
  45.  
  46.     Akey        = -3,                    //the key A
  47.     Bbkey        = -2,                    //the key B flat
  48.     Bkey        = -1,                    //the key B
  49.     Ckey        = 0,                    //the key C
  50.     Dbkey        = 1,                    //the key D flat
  51.     Dkey        = 2,                    //the key D
  52.     Ebkey        = 3,                    //the key D flat
  53.     Ekey        = 4,                    //the key E
  54.     Fkey        = 5,                    //the key F
  55.     Gbkey        = 6,                    //the key G flat
  56.     Gkey        = 7,                    //the key G
  57.     Abkey        = 8,                    //the key A flat
  58.  
  59. //These are other constants used in the SoundUnit
  60.  
  61.     kInitNone    = 0,                    //no init options
  62.     kWait        = false,                //wait for the channel
  63.     kSMAsynch    = true,                    //asynchronous Sound Manager call
  64.     kWaveSize    = 512,                    //standard size of wave table
  65.     kSyncID        = 0x12345678,            //identifier used in syncCmd
  66.     kOneSecond    = 2000,                    //one second frequency duration
  67.  
  68.     kNoSynth    = 0                        //no synth is specified
  69. };
  70.  
  71. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72. //types
  73. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74.  
  75. typedef SndCommand *SndCmdPtr;    // Ptr to a sound command, for type coersion
  76.  
  77.  
  78. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. // prototypes
  80. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81.  
  82. /*
  83. The routines below are for public consumption in this SoundUnit.  Note that
  84. these all return standard sound channels to allow easy of modifications.
  85. I can change the structure of my own sound channels and the code without
  86. forcing a change in the application that uses this SoundUnit.
  87.  
  88. VERSION 1.1: No longer putting the SANELib into a seperate segment, which then
  89. needs to be unloaded.  Instead, I merge it into the Main segment.  Refer to
  90. the Make file for more information.
  91. */
  92.  
  93. pascal void _SoundUnit(void);
  94. pascal OSErr InitSoundUnit(void);
  95. pascal Boolean HasMACE(void);
  96. pascal Boolean HasSoundInput(void);
  97. pascal Boolean HasStereoSupport(void);
  98. pascal short GetSoundMgrVersion(void);
  99. pascal Boolean HasSoundCompleted(void);
  100. pascal Boolean HasChannelOpen(void);
  101. pascal OSErr SendQuiet(SndChannelPtr chan, Boolean immediate);
  102. pascal void DoSoundComplete(void);
  103. pascal void FreeAllChans(void);
  104. pascal void FreeSoundUnit(void);
  105. pascal OSErr SoundComplete(SndChannelPtr chan);
  106. pascal OSErr HoldSnd(SndListHandle sndHandle);
  107. pascal OSErr PlaySong(SndChannelPtr chan, SndListHandle sndSong);
  108. pascal OSErr SetSquareWaveTimbre(SndChannelPtr squareChan, short timbre, Boolean immediate);
  109. pascal OSErr SendNote(SndChannelPtr chan, short duration, long note);
  110. pascal OSErr SendRest(SndChannelPtr chan, short duration);
  111. pascal OSErr GetSquareWaveChan(SndChannelPtr *squareChan, short timbre);
  112. pascal OSErr GetNoSynthChan(SndChannelPtr *chan);
  113. pascal OSErr GetSampleChan(SndChannelPtr *sampleChan, long init, SndListHandle sndInstrument);
  114. pascal OSErr Get4SampleInstruments(SndChannelPtr *chan1, SndChannelPtr *chan2, SndChannelPtr *chan3, SndChannelPtr *chan4, SndListHandle sndInstrument1, SndListHandle sndInstrument2, SndListHandle sndInstrument3, SndListHandle sndInstrument4);
  115. pascal Boolean HasWorkingWaveTables(void);
  116. pascal OSErr GetWaveChans(SndChannelPtr *waveChan1, SndChannelPtr *waveChan2, SndChannelPtr *waveChan3, SndChannelPtr *waveChan4);
  117. pascal OSErr InstallWave(SndChannelPtr waveChan, Ptr aWavePtr, short waveLength);
  118. pascal OSErr Play4ChanSongs(SndChannelPtr chan1, SndChannelPtr chan2, SndChannelPtr chan3, SndChannelPtr chan4, SndListHandle song1, SndListHandle song2, SndListHandle song3, SndListHandle song4);
  119. pascal long GetSndDataOffset(SndListHandle sndHandle, short *dataType, short *waveLength);
  120. pascal OSErr HyperSndPlay(SndListHandle sndHandle);
  121. pascal OSErr AsynchSndPlay(SndListHandle sndHandle);
  122.  
  123. #endif
  124.